<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ request.getContextPath() + "/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>员工信息</title>
</head>
<base href="<%=basePath%>">
<body>
	<%@ include file="../header.jsp"%>
	<a href="staff/add.jsp">添加</a>
	<form>
	姓名关键字：<input type="text" name="key" placeholder="请输入姓名关键字">
	<input type="submit" value="搜索">
	</form>
	<table border="1" width="100%" cellspacing="0">
	<caption>员工列表</caption>
		<tr>
			<th>ID</th>
			<th>姓名</th>
			<th>性别</th>
			<th>身份证</th>
			<th>入职时间</th>
			<th>生日</th>
			<th>部门</th>
			<th>职务</th>
			<th>状态</th>
			<th>领导ID</th>
			<th>电话</th>
			<th>邮箱</th>
			<th>工资</th>
			<th>照片</th>
			<th>操作</th>
		</tr>
		<!--遍历员工信息  -->
		<c:if test="${staffs==null }">
			<!-- 跳转页面 -->
			<jsp:forward page="../staff.do?action=list"></jsp:forward>
		</c:if>
		<c:forEach items="${staffs }" var="staff">
			<tr>
				<td>${staff.id }</td>
				<td>${staff.name }</td>
				<td>${staff.sex }</td>
				<td>${staff.idcard }</td>
				<td><fmt:formatDate value="${staff.joinTime }" pattern="yyyy-MM-dd"/></td>
				<td><fmt:formatDate value="${staff.birthday }" pattern="yyyy-MM-dd"/></td>
				<td>${staff.deptName }</td>
				<td>${staff.job }</td>
				<td>${staff.status==0?"正常":"离职" }</td>
				<td>${staff.leaderName }</td>
				<td>${staff.phone }</td>
				<td>${staff.email }</td>
				<td>${staff.salary }</td>
				<c:if test="${staff.photo!=null }">
				<td><img src="upload/${staff.photo }"width=200px></td>
				</c:if>
				<c:if test="${staff.photo==null }">
				<td><img src=""width=200px></td>
				</c:if>
				<td>
				<a href="staff.do?action=remove&id=${staff.id }">删除</a>
				<a href="staff/edit.jsp?id=${staff.id }">编辑</a>
				</td>
			</tr>
		</c:forEach>

	</table>
	<script type="text/javascript">
	 <c:if test="${param.error!=null}">
	  alert('${param.error}');
	 </c:if>
	</script>
</body>
</html>